<template>
	<view class="cotainer">


		<!-- <scroll-view scroll-y="true" :style="{height:height + 'px'}" :scroll-with-animation='true' @scrolltolower="touchbtm"
		 @scroll="scroll" :scroll-top="pos" :refresher-enabled='isvideo' :refresher-triggered="refreshstatus"
		 @refresherrefresh="refreshstart" :refresher-threshold="100">
			<slot></slot>
		</scroll-view> -->

		<scroll-view scroll-y="true" :style="{height:height + 'px'}" :scroll-with-animation='true' @scrolltolower="touchbtm"
		 @scroll="scroll" :scroll-top="pos" :scroll-into-view="scrollintoview">
			<slot></slot>
		</scroll-view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				height: '',
				pos: 0,
				oldpos: 0,
				scrollintoview: undefined,
				//refreshstatus: false,

			}
		},
		methods: {


			// refreshstart() {
			// 	this.refreshstatus = true
			// 	uni.$emit('refreshvideo', 1)
			// },


			scroll(e) {
				if (this.$Route.name == 'video') {

					// // #ifdef H5
					// this.bughelper = e.detail.scrollTop == 0 ? true : false // H5会出现的组件bug  上滚也会触发刷新
					// // #endif

					if (e.detail.scrollTop > 400) {
						this.oldpos = e.detail.scrollTop
						uni.$emit('showbacktotop', true)
					} else {
						uni.$emit('showbacktotop', false)
					}
				}
			},
			touchbtm() {
				if (this.$Route.name == 'video') {
					uni.$emit('loadmorevideo', 1)
				}
			}
		},
		created() {


			// uni.$on('yjr-refreshend', () => {
			// 	console.log(666)
			// 	this.refreshstatus = false
			// })



			uni.$on('backvideo', (e) => {
				this.scrollintoview = undefined
				this.$nextTick(() => {
					this.scrollintoview = this.$store.state.playingvideo
				})
			})

			uni.$on('backtop', () => {
				this.pos = this.oldpos //需要让pos更新一下才行
				this.$nextTick(() => {
					this.pos = 0
				})
			})

			const mobileInfo = uni.getSystemInfoSync();

			// #ifdef MP-WEIXIN
			const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
			this.height = mobileInfo.screenHeight - menuButtonInfo.bottom * 1.2 +
				mobileInfo.safeAreaInsets.bottom //tabbar高度
			// #endif

			// #ifdef H5
			this.height = mobileInfo.windowHeight - 25
			// #endif


			//h5        不用拿胶囊信息，直接用statusBarHeight
			//apk       和h5类似不用拿胶囊信息，直接用statusBarHeight
		},


		// computed: {
		// 	isvideo() {
		// 		return this.$Route.name == 'video'
		// 	}
		// }


	}
</script>

<style lang="scss">
	.cotainer {
		width: 100%;
		position: relative;
	}
</style>
